<?php
$host="db.seng.uvic.ca"; // Host name
$username="se321g01"; // Mysql username
$password="un8bi2YM"; // Mysql password
$db_name="se321g01"; // Database name
$tbl_name="user_info"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// Personal
$firstname=$_POST['ua_firstname'];
$lastname=$_POST['ua_lastname'];
$password=$_POST['ua_password'];
$del=$_POST['ua_delete'];

echo $firstname;
echo $lastname;
echo $password;
// Points and Rewards
$remainingtime=$_POST['ua_remainingtime'];
$points=$_POST['ua_points'];

// Get UID
$uid = $_GET['uid'];
$sid = $_GET['sid'];

// Update into user_info
mysql_query("UPDATE user_info 
SET first_name='$firstname', last_name='$lastname', passwd='$password' 
WHERE uid='$sid'");

// Update into user_stats
mysql_query("UPDATE user_stats 
SET time_left='$remainingtime', points='$points' 
WHERE uid='$sid'");

// Go back to profile
header("location:./profile.php?uid=" . $uid . "&sid=" . $sid . "&tab=1&updated=1");

?>
